package tech.eyao.hs60x.converts;

import java.util.List;
import java.util.stream.Collectors;

import org.apache.commons.lang3.StringUtils;
import org.springframework.util.CollectionUtils;

import tech.eyao.hs60x.dto.ApprovalDTO;
import tech.eyao.hs60x.enums.ApprovalStatus;
import tech.eyao.hs60x.model.domain.ApprovalDO;

public class ApprovalConvert {

	public static List<ApprovalDTO> convert(List<ApprovalDO> approvalDOs) {

		if (CollectionUtils.isEmpty(approvalDOs)) {
			return null;
		}

		List<ApprovalDTO> lists = approvalDOs.stream().filter(a -> a.getStatus() == ApprovalStatus.NO.getValue())
				.map(a -> new ApprovalDTO(a.getId(), a.getType(), a.getFriendNickName(), a.getGmtCreated(), StringUtils.defaultString(a.getFriendPhone()), a.getWatchId()))
				.collect(Collectors.toList());
		return lists;
	}
}
